﻿using Raven;
using UnityEngine;
using Vector2 = Raven.Vector2;
using Vector3 = UnityEngine.Vector3;

public class Wall2DDisplay : UnityDisplayObject
{
    private Wall2D _wall2D;

    public Wall2DDisplay(BaseGameEntity entity) : base(entity)
    {
        _wall2D = entity as Wall2D;
    }

    public override void Start()
    {
        base.Start();

        Vector2 from = _wall2D.From();
        Vector2 to = _wall2D.To();
        _gameObject.AddComponent<MeshFilter>().mesh =
            MeshFactory.LineMesh(new Vector3((float) from.x, (float) from.y), new Vector3((float) to.x, (float) to.y),
                Color.black);
        MeshRenderer render = _gameObject.AddComponent<MeshRenderer>();
        render.material = new Material(Shader.Find("Sprites/Default"));
    }

    public override void Update()
    {
    }
}